<%@ page import="ru.spbu.mm.diploma.client.service.SessionService" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="t" uri="http://myfaces.apache.org/tomahawk" %>
<%@ page contentType="text/html; charset=utf-8" language="java" %>
<%
    if (!SessionService.getInstance().checkRights((Integer)SessionService.getInstance().getSession().getAttribute("USERROLE_ID"), "sec_admin.jsp")) {
        response.sendRedirect("accessError.faces");
    }
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Admin area.</title>
    <link href="css/css_project_table.css" rel="stylesheet" type="text/css"/>
</head>

<body>

<div class="container">
    <div class="header"><!-- end .header -->
        <f:view>
        <h:form>
        <table width="960" border="1">
            <tr>
                <td width="840">&nbsp;</td>
                <td width="100">


                    <h:commandButton action="#{loginController.logOut}" value="LogOut Intra"
                                     accesskey="l" immediate="true" styleClass="submit">
                    </h:commandButton>
                    </h:form>

                </td>
            </tr>
        </table>
    </div>
    <div class="content">


        Create new user:

        <h:form binding="#{adminController.newUserForm}"
                styleClass="item" id="newUserForm">
            <h:panelGrid columns="2">

                <h:panelGroup>
                    <h:outputText value="#{msg.username}"/>
                </h:panelGroup>
                <h:panelGroup>
                    <h:inputText value="#{adminController.user.username}" id="username" required="true"
                                 requiredMessage="Username is required"/>
                    <h:message for="username" styleClass="errors"/>
                </h:panelGroup>

                <h:panelGroup>
                    <h:outputText value="#{msg.password}"/>
                </h:panelGroup>
                <h:panelGroup>
                    <h:inputText value="#{adminController.user.password}" id="password" required="true"
                                 requiredMessage="Password is required"/>
                    <h:message for="password" styleClass="errors"/>
                </h:panelGroup>

                <h:panelGroup>
                    <h:outputText value="#{msg.userrole}"/>
                </h:panelGroup>
                <h:panelGroup>
                    <h:selectOneMenu value="#{adminController.user.userroleID}">
                        <f:selectItems value="#{adminController.userroleList}"/>
                    </h:selectOneMenu>
                </h:panelGroup>

            </h:panelGrid>

            <h:panelGroup>
                <h:commandButton action="#{adminController.save}" value="#{msg.save}"
                                 accesskey="s">
                </h:commandButton>
                <h:commandButton action="#{adminController.cancel}" value="#{msg.cancel}"
                                 accesskey="c" immediate="true">
                </h:commandButton>
            </h:panelGroup>

        </h:form>
        </f:view>
        <!-- end .content --></div>
    <div class="footer">
        <p>Нижний колонтитул</p>
        <!-- end .footer --></div>
    <!-- end .container --></div>
</body>
</html>